package kr.saeildamil.androidstudy.exam;

import kr.saeildamil.androiddforstudy.R;
import android.app.Activity;
import android.media.AudioManager;
import android.media.MediaPlayer;
import android.media.SoundPool;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;

public class Beep extends Activity {
	SoundPool mpool;
	int mddok;
	AudioManager mam;
	
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.beep);
		
		mpool = new SoundPool(1, AudioManager.STREAM_MUSIC, 0);
		mddok = mpool.load(this, R.raw.ddok, 1);
		mam = (AudioManager) getSystemService(AUDIO_SERVICE);
		
		findViewById(R.id.play1).setOnClickListener(mClickListener);
		findViewById(R.id.play2).setOnClickListener(mClickListener);
		
	}
		Button.OnClickListener mClickListener = new Button.OnClickListener(){

			@Override
			public void onClick(View v) {
				MediaPlayer player;
				switch (v.getId()) {
				case R.id.play1:
					mpool.play(mddok, 1, 1, 0, 0, 1);
					break;
				case R.id.play2:
					mam.playSoundEffect(AudioManager.FX_KEYPRESS_STANDARD);
					break;
				}
			}
			
		};
	}


